import 'dart:io';
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:uuid/uuid.dart';

void toast(String msg) {
  Fluttertoast.showToast(
    msg: msg,
    textColor: Colors.black,
    backgroundColor: Colors.white,
    gravity: ToastGravity.CENTER
  );
}

Color getRandomColor({int alpha = 255}) {
  final random = Random();
  return Color.fromARGB(
    alpha,
    random.nextInt(256),
    random.nextInt(256),
    random.nextInt(256),
  );
}

MaterialColor getRandomMaterialColor() {
  const materialColors = <MaterialColor>[
    Colors.red,
    Colors.pink,
    Colors.purple,
    Colors.deepPurple,
    Colors.indigo,
    Colors.blue,
    Colors.lightBlue,
    Colors.cyan,
    Colors.teal,
    Colors.green,
    Colors.lightGreen,
    Colors.lime,
    Colors.yellow,
    Colors.amber,
    Colors.orange,
    Colors.deepOrange,
    Colors.brown,
    Colors.blueGrey,
  ];
  final random = Random();
  return materialColors[random.nextInt(materialColors.length)];
}

///获取操作系统名称
String getOsName() {
  if (Platform.isAndroid) return 'Android';
  if (Platform.isIOS) return 'iOS';
  if (Platform.isWindows) return 'Windows';
  if (Platform.isMacOS) return 'macOS';
  if (Platform.isLinux) return 'Linux';
  if (Platform.isFuchsia) return 'Fuchsia';
  return "ohos";
}

String getTest(){
  return "测试fyc";
}

///生成32的UUID
String obtainCode() {
  return const Uuid().v4().replaceAll('-', '');
}